blob: 6dffdb21fde46aa029f9fb8d81863a2fa91ba117 [file] [log] [blame]
Howard Hinnant8f73c632010-09-27 21:17:381// -*- C++ -*-
2//===--------------------------- atomic -----------------------------------===//
3//
4// The LLVM Compiler Infrastructure
5//
6// This file is distributed under the University of Illinois Open Source
7// License. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_ATOMIC
12#define _LIBCPP_ATOMIC
13
14/*
15 atomic synopsis
16
17namespace std
18{
19
20// order and consistency
21
22typedef enum memory_order
23{
Howard Hinnantd1176e22010-09-28 17:13:3824 memory_order_relaxed,
25 memory_order_consume, // load-consume
26 memory_order_acquire, // load-acquire
27 memory_order_release, // store-release
28 memory_order_acq_rel, // store-release load-acquire
29 memory_order_seq_cst // store-release load-acquire
Howard Hinnant8f73c632010-09-27 21:17:3830} memory_order;
31
Howard Hinnant300c67a2012-04-11 20:14:2132template <class T> T kill_dependency(T y) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:3833
34// lock-free property
35
36#define ATOMIC_CHAR_LOCK_FREE unspecified
37#define ATOMIC_CHAR16_T_LOCK_FREE unspecified
38#define ATOMIC_CHAR32_T_LOCK_FREE unspecified
39#define ATOMIC_WCHAR_T_LOCK_FREE unspecified
40#define ATOMIC_SHORT_LOCK_FREE unspecified
41#define ATOMIC_INT_LOCK_FREE unspecified
42#define ATOMIC_LONG_LOCK_FREE unspecified
43#define ATOMIC_LLONG_LOCK_FREE unspecified
Howard Hinnant8f73c632010-09-27 21:17:3844
Howard Hinnant8f73c632010-09-27 21:17:3845// flag type and operations
46
47typedef struct atomic_flag
48{
Howard Hinnant300c67a2012-04-11 20:14:2149 bool test_and_set(memory_order m = memory_order_seq_cst) volatile noexcept;
50 bool test_and_set(memory_order m = memory_order_seq_cst) noexcept;
51 void clear(memory_order m = memory_order_seq_cst) volatile noexcept;
52 void clear(memory_order m = memory_order_seq_cst) noexcept;
53 atomic_flag() noexcept = default;
Howard Hinnant8f73c632010-09-27 21:17:3854 atomic_flag(const atomic_flag&) = delete;
55 atomic_flag& operator=(const atomic_flag&) = delete;
56 atomic_flag& operator=(const atomic_flag&) volatile = delete;
57} atomic_flag;
58
Howard Hinnant4777bf22010-12-06 23:10:0859bool
Howard Hinnant300c67a2012-04-11 20:14:2160 atomic_flag_test_and_set(volatile atomic_flag* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:0861
62bool
Howard Hinnant300c67a2012-04-11 20:14:2163 atomic_flag_test_and_set(atomic_flag* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:0864
65bool
66 atomic_flag_test_and_set_explicit(volatile atomic_flag* obj,
Howard Hinnant300c67a2012-04-11 20:14:2167 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:0868
69bool
Howard Hinnant300c67a2012-04-11 20:14:2170 atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:0871
72void
Howard Hinnant300c67a2012-04-11 20:14:2173 atomic_flag_clear(volatile atomic_flag* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:0874
75void
Howard Hinnant300c67a2012-04-11 20:14:2176 atomic_flag_clear(atomic_flag* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:0877
78void
Howard Hinnant300c67a2012-04-11 20:14:2179 atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:0880
81void
Howard Hinnant300c67a2012-04-11 20:14:2182 atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:3883
84#define ATOMIC_FLAG_INIT see below
Howard Hinnante7385012010-10-19 16:51:1885#define ATOMIC_VAR_INIT(value) see below
Howard Hinnant8f73c632010-09-27 21:17:3886
Howard Hinnant8f73c632010-09-27 21:17:3887template <class T>
88struct atomic
89{
Howard Hinnant300c67a2012-04-11 20:14:2190 bool is_lock_free() const volatile noexcept;
91 bool is_lock_free() const noexcept;
92 void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
93 void store(T desr, memory_order m = memory_order_seq_cst) noexcept;
94 T load(memory_order m = memory_order_seq_cst) const volatile noexcept;
95 T load(memory_order m = memory_order_seq_cst) const noexcept;
96 operator T() const volatile noexcept;
97 operator T() const noexcept;
98 T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
99 T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08100 bool compare_exchange_weak(T& expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21101 memory_order s, memory_order f) volatile noexcept;
102 bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08103 bool compare_exchange_strong(T& expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21104 memory_order s, memory_order f) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08105 bool compare_exchange_strong(T& expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21106 memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08107 bool compare_exchange_weak(T& expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21108 memory_order m = memory_order_seq_cst) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08109 bool compare_exchange_weak(T& expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21110 memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08111 bool compare_exchange_strong(T& expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21112 memory_order m = memory_order_seq_cst) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08113 bool compare_exchange_strong(T& expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21114 memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38115
Howard Hinnant300c67a2012-04-11 20:14:21116 atomic() noexcept = default;
117 constexpr atomic(T desr) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38118 atomic(const atomic&) = delete;
119 atomic& operator=(const atomic&) = delete;
120 atomic& operator=(const atomic&) volatile = delete;
Howard Hinnant300c67a2012-04-11 20:14:21121 T operator=(T) volatile noexcept;
122 T operator=(T) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38123};
124
125template <>
Howard Hinnant4777bf22010-12-06 23:10:08126struct atomic<integral>
Howard Hinnant8f73c632010-09-27 21:17:38127{
Howard Hinnant300c67a2012-04-11 20:14:21128 bool is_lock_free() const volatile noexcept;
129 bool is_lock_free() const noexcept;
130 void store(integral desr, memory_order m = memory_order_seq_cst) volatile noexcept;
131 void store(integral desr, memory_order m = memory_order_seq_cst) noexcept;
132 integral load(memory_order m = memory_order_seq_cst) const volatile noexcept;
133 integral load(memory_order m = memory_order_seq_cst) const noexcept;
134 operator integral() const volatile noexcept;
135 operator integral() const noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08136 integral exchange(integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21137 memory_order m = memory_order_seq_cst) volatile noexcept;
138 integral exchange(integral desr, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08139 bool compare_exchange_weak(integral& expc, integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21140 memory_order s, memory_order f) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08141 bool compare_exchange_weak(integral& expc, integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21142 memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08143 bool compare_exchange_strong(integral& expc, integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21144 memory_order s, memory_order f) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08145 bool compare_exchange_strong(integral& expc, integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21146 memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08147 bool compare_exchange_weak(integral& expc, integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21148 memory_order m = memory_order_seq_cst) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08149 bool compare_exchange_weak(integral& expc, integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21150 memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08151 bool compare_exchange_strong(integral& expc, integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21152 memory_order m = memory_order_seq_cst) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08153 bool compare_exchange_strong(integral& expc, integral desr,
Howard Hinnant300c67a2012-04-11 20:14:21154 memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38155
Howard Hinnant4777bf22010-12-06 23:10:08156 integral
Howard Hinnant300c67a2012-04-11 20:14:21157 fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
158 integral fetch_add(integral op, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08159 integral
Howard Hinnant300c67a2012-04-11 20:14:21160 fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
161 integral fetch_sub(integral op, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08162 integral
Howard Hinnant300c67a2012-04-11 20:14:21163 fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
164 integral fetch_and(integral op, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08165 integral
Howard Hinnant300c67a2012-04-11 20:14:21166 fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
167 integral fetch_or(integral op, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08168 integral
Howard Hinnant300c67a2012-04-11 20:14:21169 fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
170 integral fetch_xor(integral op, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38171
Howard Hinnant300c67a2012-04-11 20:14:21172 atomic() noexcept = default;
173 constexpr atomic(integral desr) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38174 atomic(const atomic&) = delete;
175 atomic& operator=(const atomic&) = delete;
176 atomic& operator=(const atomic&) volatile = delete;
Howard Hinnant300c67a2012-04-11 20:14:21177 integral operator=(integral desr) volatile noexcept;
178 integral operator=(integral desr) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38179
Howard Hinnant300c67a2012-04-11 20:14:21180 integral operator++(int) volatile noexcept;
181 integral operator++(int) noexcept;
182 integral operator--(int) volatile noexcept;
183 integral operator--(int) noexcept;
184 integral operator++() volatile noexcept;
185 integral operator++() noexcept;
186 integral operator--() volatile noexcept;
187 integral operator--() noexcept;
188 integral operator+=(integral op) volatile noexcept;
189 integral operator+=(integral op) noexcept;
190 integral operator-=(integral op) volatile noexcept;
191 integral operator-=(integral op) noexcept;
192 integral operator&=(integral op) volatile noexcept;
193 integral operator&=(integral op) noexcept;
194 integral operator|=(integral op) volatile noexcept;
195 integral operator|=(integral op) noexcept;
196 integral operator^=(integral op) volatile noexcept;
197 integral operator^=(integral op) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38198};
199
200template <class T>
201struct atomic<T*>
Howard Hinnant8f73c632010-09-27 21:17:38202{
Howard Hinnant300c67a2012-04-11 20:14:21203 bool is_lock_free() const volatile noexcept;
204 bool is_lock_free() const noexcept;
205 void store(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept;
206 void store(T* desr, memory_order m = memory_order_seq_cst) noexcept;
207 T* load(memory_order m = memory_order_seq_cst) const volatile noexcept;
208 T* load(memory_order m = memory_order_seq_cst) const noexcept;
209 operator T*() const volatile noexcept;
210 operator T*() const noexcept;
211 T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept;
212 T* exchange(T* desr, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08213 bool compare_exchange_weak(T*& expc, T* desr,
Howard Hinnant300c67a2012-04-11 20:14:21214 memory_order s, memory_order f) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08215 bool compare_exchange_weak(T*& expc, T* desr,
Howard Hinnant300c67a2012-04-11 20:14:21216 memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08217 bool compare_exchange_strong(T*& expc, T* desr,
Howard Hinnant300c67a2012-04-11 20:14:21218 memory_order s, memory_order f) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08219 bool compare_exchange_strong(T*& expc, T* desr,
Howard Hinnant300c67a2012-04-11 20:14:21220 memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08221 bool compare_exchange_weak(T*& expc, T* desr,
Howard Hinnant300c67a2012-04-11 20:14:21222 memory_order m = memory_order_seq_cst) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08223 bool compare_exchange_weak(T*& expc, T* desr,
Howard Hinnant300c67a2012-04-11 20:14:21224 memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08225 bool compare_exchange_strong(T*& expc, T* desr,
Howard Hinnant300c67a2012-04-11 20:14:21226 memory_order m = memory_order_seq_cst) volatile noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08227 bool compare_exchange_strong(T*& expc, T* desr,
Howard Hinnant300c67a2012-04-11 20:14:21228 memory_order m = memory_order_seq_cst) noexcept;
229 T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept;
230 T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept;
231 T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept;
232 T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08233
Howard Hinnant300c67a2012-04-11 20:14:21234 atomic() noexcept = default;
235 constexpr atomic(T* desr) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38236 atomic(const atomic&) = delete;
237 atomic& operator=(const atomic&) = delete;
238 atomic& operator=(const atomic&) volatile = delete;
Howard Hinnant4777bf22010-12-06 23:10:08239
Howard Hinnant300c67a2012-04-11 20:14:21240 T* operator=(T*) volatile noexcept;
241 T* operator=(T*) noexcept;
242 T* operator++(int) volatile noexcept;
243 T* operator++(int) noexcept;
244 T* operator--(int) volatile noexcept;
245 T* operator--(int) noexcept;
246 T* operator++() volatile noexcept;
247 T* operator++() noexcept;
248 T* operator--() volatile noexcept;
249 T* operator--() noexcept;
250 T* operator+=(ptrdiff_t op) volatile noexcept;
251 T* operator+=(ptrdiff_t op) noexcept;
252 T* operator-=(ptrdiff_t op) volatile noexcept;
253 T* operator-=(ptrdiff_t op) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38254};
255
Howard Hinnant4777bf22010-12-06 23:10:08256
257template <class T>
258 bool
Howard Hinnant300c67a2012-04-11 20:14:21259 atomic_is_lock_free(const volatile atomic<T>* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08260
261template <class T>
262 bool
Howard Hinnant300c67a2012-04-11 20:14:21263 atomic_is_lock_free(const atomic<T>* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08264
265template <class T>
266 void
Howard Hinnant300c67a2012-04-11 20:14:21267 atomic_init(volatile atomic<T>* obj, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08268
269template <class T>
270 void
Howard Hinnant300c67a2012-04-11 20:14:21271 atomic_init(atomic<T>* obj, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08272
273template <class T>
274 void
Howard Hinnant300c67a2012-04-11 20:14:21275 atomic_store(volatile atomic<T>* obj, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08276
277template <class T>
278 void
Howard Hinnant300c67a2012-04-11 20:14:21279 atomic_store(atomic<T>* obj, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08280
281template <class T>
282 void
Howard Hinnant300c67a2012-04-11 20:14:21283 atomic_store_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08284
285template <class T>
286 void
Howard Hinnant300c67a2012-04-11 20:14:21287 atomic_store_explicit(atomic<T>* obj, T desr, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08288
289template <class T>
290 T
Howard Hinnant300c67a2012-04-11 20:14:21291 atomic_load(const volatile atomic<T>* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08292
293template <class T>
294 T
Howard Hinnant300c67a2012-04-11 20:14:21295 atomic_load(const atomic<T>* obj) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08296
297template <class T>
298 T
Howard Hinnant300c67a2012-04-11 20:14:21299 atomic_load_explicit(const volatile atomic<T>* obj, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08300
301template <class T>
302 T
Howard Hinnant300c67a2012-04-11 20:14:21303 atomic_load_explicit(const atomic<T>* obj, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08304
305template <class T>
306 T
Howard Hinnant300c67a2012-04-11 20:14:21307 atomic_exchange(volatile atomic<T>* obj, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08308
309template <class T>
310 T
Howard Hinnant300c67a2012-04-11 20:14:21311 atomic_exchange(atomic<T>* obj, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08312
313template <class T>
314 T
Howard Hinnant300c67a2012-04-11 20:14:21315 atomic_exchange_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08316
317template <class T>
318 T
Howard Hinnant300c67a2012-04-11 20:14:21319 atomic_exchange_explicit(atomic<T>* obj, T desr, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08320
321template <class T>
322 bool
Howard Hinnant300c67a2012-04-11 20:14:21323 atomic_compare_exchange_weak(volatile atomic<T>* obj, T* expc, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08324
325template <class T>
326 bool
Howard Hinnant300c67a2012-04-11 20:14:21327 atomic_compare_exchange_weak(atomic<T>* obj, T* expc, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08328
329template <class T>
330 bool
Howard Hinnant300c67a2012-04-11 20:14:21331 atomic_compare_exchange_strong(volatile atomic<T>* obj, T* expc, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08332
333template <class T>
334 bool
Howard Hinnant300c67a2012-04-11 20:14:21335 atomic_compare_exchange_strong(atomic<T>* obj, T* expc, T desr) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08336
337template <class T>
338 bool
339 atomic_compare_exchange_weak_explicit(volatile atomic<T>* obj, T* expc,
340 T desr,
Howard Hinnant300c67a2012-04-11 20:14:21341 memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08342
343template <class T>
344 bool
345 atomic_compare_exchange_weak_explicit(atomic<T>* obj, T* expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21346 memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08347
348template <class T>
349 bool
350 atomic_compare_exchange_strong_explicit(volatile atomic<T>* obj,
351 T* expc, T desr,
Howard Hinnant300c67a2012-04-11 20:14:21352 memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08353
354template <class T>
355 bool
356 atomic_compare_exchange_strong_explicit(atomic<T>* obj, T* expc,
357 T desr,
Howard Hinnant300c67a2012-04-11 20:14:21358 memory_order s, memory_order f) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08359
360template <class Integral>
361 Integral
Howard Hinnant300c67a2012-04-11 20:14:21362 atomic_fetch_add(volatile atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08363
364template <class Integral>
365 Integral
Howard Hinnant300c67a2012-04-11 20:14:21366 atomic_fetch_add(atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08367
368template <class Integral>
369 Integral
370 atomic_fetch_add_explicit(volatile atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21371 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08372template <class Integral>
373 Integral
374 atomic_fetch_add_explicit(atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21375 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08376template <class Integral>
377 Integral
Howard Hinnant300c67a2012-04-11 20:14:21378 atomic_fetch_sub(volatile atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08379
380template <class Integral>
381 Integral
Howard Hinnant300c67a2012-04-11 20:14:21382 atomic_fetch_sub(atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08383
384template <class Integral>
385 Integral
386 atomic_fetch_sub_explicit(volatile atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21387 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08388template <class Integral>
389 Integral
390 atomic_fetch_sub_explicit(atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21391 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08392template <class Integral>
393 Integral
Howard Hinnant300c67a2012-04-11 20:14:21394 atomic_fetch_and(volatile atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08395
396template <class Integral>
397 Integral
Howard Hinnant300c67a2012-04-11 20:14:21398 atomic_fetch_and(atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08399
400template <class Integral>
401 Integral
402 atomic_fetch_and_explicit(volatile atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21403 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08404template <class Integral>
405 Integral
406 atomic_fetch_and_explicit(atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21407 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08408template <class Integral>
409 Integral
Howard Hinnant300c67a2012-04-11 20:14:21410 atomic_fetch_or(volatile atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08411
412template <class Integral>
413 Integral
Howard Hinnant300c67a2012-04-11 20:14:21414 atomic_fetch_or(atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08415
416template <class Integral>
417 Integral
418 atomic_fetch_or_explicit(volatile atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21419 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08420template <class Integral>
421 Integral
422 atomic_fetch_or_explicit(atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21423 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08424template <class Integral>
425 Integral
Howard Hinnant300c67a2012-04-11 20:14:21426 atomic_fetch_xor(volatile atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08427
428template <class Integral>
429 Integral
Howard Hinnant300c67a2012-04-11 20:14:21430 atomic_fetch_xor(atomic<Integral>* obj, Integral op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08431
432template <class Integral>
433 Integral
434 atomic_fetch_xor_explicit(volatile atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21435 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08436template <class Integral>
437 Integral
438 atomic_fetch_xor_explicit(atomic<Integral>* obj, Integral op,
Howard Hinnant300c67a2012-04-11 20:14:21439 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08440
441template <class T>
442 T*
Howard Hinnant300c67a2012-04-11 20:14:21443 atomic_fetch_add(volatile atomic<T*>* obj, ptrdiff_t op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08444
445template <class T>
446 T*
Howard Hinnant300c67a2012-04-11 20:14:21447 atomic_fetch_add(atomic<T*>* obj, ptrdiff_t op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08448
449template <class T>
450 T*
451 atomic_fetch_add_explicit(volatile atomic<T*>* obj, ptrdiff_t op,
Howard Hinnant300c67a2012-04-11 20:14:21452 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08453template <class T>
454 T*
Howard Hinnant300c67a2012-04-11 20:14:21455 atomic_fetch_add_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08456
457template <class T>
458 T*
Howard Hinnant300c67a2012-04-11 20:14:21459 atomic_fetch_sub(volatile atomic<T*>* obj, ptrdiff_t op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08460
461template <class T>
462 T*
Howard Hinnant300c67a2012-04-11 20:14:21463 atomic_fetch_sub(atomic<T*>* obj, ptrdiff_t op) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08464
465template <class T>
466 T*
467 atomic_fetch_sub_explicit(volatile atomic<T*>* obj, ptrdiff_t op,
Howard Hinnant300c67a2012-04-11 20:14:21468 memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08469template <class T>
470 T*
Howard Hinnant300c67a2012-04-11 20:14:21471 atomic_fetch_sub_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept;
Howard Hinnant4777bf22010-12-06 23:10:08472
473// Atomics for standard typedef types
474
475typedef atomic<char> atomic_char;
476typedef atomic<signed char> atomic_schar;
477typedef atomic<unsigned char> atomic_uchar;
478typedef atomic<short> atomic_short;
479typedef atomic<unsigned short> atomic_ushort;
480typedef atomic<int> atomic_int;
481typedef atomic<unsigned int> atomic_uint;
482typedef atomic<long> atomic_long;
483typedef atomic<unsigned long> atomic_ulong;
484typedef atomic<long long> atomic_llong;
485typedef atomic<unsigned long long> atomic_ullong;
486typedef atomic<char16_t> atomic_char16_t;
487typedef atomic<char32_t> atomic_char32_t;
488typedef atomic<wchar_t> atomic_wchar_t;
489
490typedef atomic<int_least8_t> atomic_int_least8_t;
491typedef atomic<uint_least8_t> atomic_uint_least8_t;
492typedef atomic<int_least16_t> atomic_int_least16_t;
493typedef atomic<uint_least16_t> atomic_uint_least16_t;
494typedef atomic<int_least32_t> atomic_int_least32_t;
495typedef atomic<uint_least32_t> atomic_uint_least32_t;
496typedef atomic<int_least64_t> atomic_int_least64_t;
497typedef atomic<uint_least64_t> atomic_uint_least64_t;
498
499typedef atomic<int_fast8_t> atomic_int_fast8_t;
500typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
501typedef atomic<int_fast16_t> atomic_int_fast16_t;
502typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
503typedef atomic<int_fast32_t> atomic_int_fast32_t;
504typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
505typedef atomic<int_fast64_t> atomic_int_fast64_t;
506typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
507
508typedef atomic<intptr_t> atomic_intptr_t;
509typedef atomic<uintptr_t> atomic_uintptr_t;
510typedef atomic<size_t> atomic_size_t;
511typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
512typedef atomic<intmax_t> atomic_intmax_t;
513typedef atomic<uintmax_t> atomic_uintmax_t;
514
Howard Hinnant8f73c632010-09-27 21:17:38515// fences
516
Howard Hinnant300c67a2012-04-11 20:14:21517void atomic_thread_fence(memory_order m) noexcept;
518void atomic_signal_fence(memory_order m) noexcept;
Howard Hinnant8f73c632010-09-27 21:17:38519
520} // std
521
522*/
523
524#include <__config>
Howard Hinnant4777bf22010-12-06 23:10:08525#include <cstddef>
526#include <cstdint>
527#include <type_traits>
Howard Hinnant8f73c632010-09-27 21:17:38528
Howard Hinnant08e17472011-10-17 20:05:10529#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnant8f73c632010-09-27 21:17:38530#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10531#endif
Howard Hinnant8f73c632010-09-27 21:17:38532
533_LIBCPP_BEGIN_NAMESPACE_STD
534
Howard Hinnant154002b2011-03-31 16:39:39535#if !__has_feature(cxx_atomic)
536#error <atomic> is not implemented
537#else
538
Howard Hinnantd1176e22010-09-28 17:13:38539typedef enum memory_order
540{
541 memory_order_relaxed, memory_order_consume, memory_order_acquire,
542 memory_order_release, memory_order_acq_rel, memory_order_seq_cst
543} memory_order;
544
545template <class _Tp>
546inline _LIBCPP_INLINE_VISIBILITY
547_Tp
Howard Hinnant300c67a2012-04-11 20:14:21548kill_dependency(_Tp __y) _NOEXCEPT
Howard Hinnantd1176e22010-09-28 17:13:38549{
550 return __y;
551}
Howard Hinnant8f73c632010-09-27 21:17:38552
Howard Hinnant91e2f262010-12-07 20:46:14553// general atomic<T>
554
555template <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value>
556struct __atomic_base // false
557{
Howard Hinnant7eb9f1e2012-09-16 20:33:09558 mutable _Atomic(_Tp) __a_;
Howard Hinnant91e2f262010-12-07 20:46:14559
560 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21561 bool is_lock_free() const volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46562 {return __c11_atomic_is_lock_free(sizeof(_Tp));}
Howard Hinnant91e2f262010-12-07 20:46:14563 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21564 bool is_lock_free() const _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46565 {return __c11_atomic_is_lock_free(sizeof(_Tp));}
Howard Hinnant91e2f262010-12-07 20:46:14566 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21567 void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46568 {__c11_atomic_store(&__a_, __d, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14569 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21570 void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46571 {__c11_atomic_store(&__a_, __d, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14572 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21573 _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46574 {return __c11_atomic_load(&__a_, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14575 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21576 _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46577 {return __c11_atomic_load(&__a_, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14578 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21579 operator _Tp() const volatile _NOEXCEPT {return load();}
Howard Hinnant91e2f262010-12-07 20:46:14580 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21581 operator _Tp() const _NOEXCEPT {return load();}
Howard Hinnant91e2f262010-12-07 20:46:14582 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21583 _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46584 {return __c11_atomic_exchange(&__a_, __d, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14585 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21586 _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46587 {return __c11_atomic_exchange(&__a_, __d, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14588 _LIBCPP_INLINE_VISIBILITY
589 bool compare_exchange_weak(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21590 memory_order __s, memory_order __f) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46591 {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
Howard Hinnant91e2f262010-12-07 20:46:14592 _LIBCPP_INLINE_VISIBILITY
593 bool compare_exchange_weak(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21594 memory_order __s, memory_order __f) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46595 {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
Howard Hinnant91e2f262010-12-07 20:46:14596 _LIBCPP_INLINE_VISIBILITY
597 bool compare_exchange_strong(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21598 memory_order __s, memory_order __f) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46599 {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
Howard Hinnant91e2f262010-12-07 20:46:14600 _LIBCPP_INLINE_VISIBILITY
601 bool compare_exchange_strong(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21602 memory_order __s, memory_order __f) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46603 {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
Howard Hinnant91e2f262010-12-07 20:46:14604 _LIBCPP_INLINE_VISIBILITY
605 bool compare_exchange_weak(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21606 memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46607 {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14608 _LIBCPP_INLINE_VISIBILITY
609 bool compare_exchange_weak(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21610 memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46611 {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14612 _LIBCPP_INLINE_VISIBILITY
613 bool compare_exchange_strong(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21614 memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46615 {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14616 _LIBCPP_INLINE_VISIBILITY
617 bool compare_exchange_strong(_Tp& __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21618 memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46619 {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14620
621 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21622 __atomic_base() _NOEXCEPT {} // = default;
Howard Hinnant91e2f262010-12-07 20:46:14623 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21624 _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}
Howard Hinnant770d1c42010-12-08 17:20:28625#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
Howard Hinnant91e2f262010-12-07 20:46:14626 __atomic_base(const __atomic_base&) = delete;
627 __atomic_base& operator=(const __atomic_base&) = delete;
628 __atomic_base& operator=(const __atomic_base&) volatile = delete;
Howard Hinnant770d1c42010-12-08 17:20:28629#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
630private:
631 __atomic_base(const __atomic_base&);
632 __atomic_base& operator=(const __atomic_base&);
633 __atomic_base& operator=(const __atomic_base&) volatile;
634#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
Howard Hinnant91e2f262010-12-07 20:46:14635};
636
637// atomic<Integral>
638
639template <class _Tp>
640struct __atomic_base<_Tp, true>
641 : public __atomic_base<_Tp, false>
642{
643 typedef __atomic_base<_Tp, false> __base;
644 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21645 __atomic_base() _NOEXCEPT {} // = default;
Howard Hinnant91e2f262010-12-07 20:46:14646 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21647 _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {}
Howard Hinnant91e2f262010-12-07 20:46:14648
649 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21650 _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46651 {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14652 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21653 _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46654 {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14655 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21656 _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46657 {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14658 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21659 _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46660 {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14661 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21662 _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46663 {return __c11_atomic_fetch_and(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14664 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21665 _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46666 {return __c11_atomic_fetch_and(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14667 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21668 _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46669 {return __c11_atomic_fetch_or(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14670 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21671 _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46672 {return __c11_atomic_fetch_or(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14673 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21674 _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46675 {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14676 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21677 _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46678 {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14679
680 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21681 _Tp operator++(int) volatile _NOEXCEPT {return fetch_add(_Tp(1));}
Howard Hinnant91e2f262010-12-07 20:46:14682 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21683 _Tp operator++(int) _NOEXCEPT {return fetch_add(_Tp(1));}
Howard Hinnant91e2f262010-12-07 20:46:14684 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21685 _Tp operator--(int) volatile _NOEXCEPT {return fetch_sub(_Tp(1));}
Howard Hinnant91e2f262010-12-07 20:46:14686 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21687 _Tp operator--(int) _NOEXCEPT {return fetch_sub(_Tp(1));}
Howard Hinnant91e2f262010-12-07 20:46:14688 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21689 _Tp operator++() volatile _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);}
Howard Hinnant91e2f262010-12-07 20:46:14690 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21691 _Tp operator++() _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);}
Howard Hinnant91e2f262010-12-07 20:46:14692 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21693 _Tp operator--() volatile _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);}
Howard Hinnant91e2f262010-12-07 20:46:14694 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21695 _Tp operator--() _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);}
Howard Hinnant91e2f262010-12-07 20:46:14696 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21697 _Tp operator+=(_Tp __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;}
Howard Hinnant91e2f262010-12-07 20:46:14698 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21699 _Tp operator+=(_Tp __op) _NOEXCEPT {return fetch_add(__op) + __op;}
Howard Hinnant91e2f262010-12-07 20:46:14700 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21701 _Tp operator-=(_Tp __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;}
Howard Hinnant91e2f262010-12-07 20:46:14702 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21703 _Tp operator-=(_Tp __op) _NOEXCEPT {return fetch_sub(__op) - __op;}
Howard Hinnant91e2f262010-12-07 20:46:14704 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21705 _Tp operator&=(_Tp __op) volatile _NOEXCEPT {return fetch_and(__op) & __op;}
Howard Hinnant91e2f262010-12-07 20:46:14706 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21707 _Tp operator&=(_Tp __op) _NOEXCEPT {return fetch_and(__op) & __op;}
Howard Hinnant91e2f262010-12-07 20:46:14708 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21709 _Tp operator|=(_Tp __op) volatile _NOEXCEPT {return fetch_or(__op) | __op;}
Howard Hinnant91e2f262010-12-07 20:46:14710 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21711 _Tp operator|=(_Tp __op) _NOEXCEPT {return fetch_or(__op) | __op;}
Howard Hinnant91e2f262010-12-07 20:46:14712 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21713 _Tp operator^=(_Tp __op) volatile _NOEXCEPT {return fetch_xor(__op) ^ __op;}
Howard Hinnant91e2f262010-12-07 20:46:14714 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21715 _Tp operator^=(_Tp __op) _NOEXCEPT {return fetch_xor(__op) ^ __op;}
Howard Hinnant91e2f262010-12-07 20:46:14716};
717
718// atomic<T>
719
720template <class _Tp>
721struct atomic
722 : public __atomic_base<_Tp>
723{
724 typedef __atomic_base<_Tp> __base;
725 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21726 atomic() _NOEXCEPT {} // = default;
Howard Hinnant91e2f262010-12-07 20:46:14727 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21728 _LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {}
Howard Hinnantd2f6afb2010-12-07 23:24:41729
730 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21731 _Tp operator=(_Tp __d) volatile _NOEXCEPT
Howard Hinnantd2f6afb2010-12-07 23:24:41732 {__base::store(__d); return __d;}
733 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21734 _Tp operator=(_Tp __d) _NOEXCEPT
Howard Hinnantd2f6afb2010-12-07 23:24:41735 {__base::store(__d); return __d;}
Howard Hinnant91e2f262010-12-07 20:46:14736};
737
738// atomic<T*>
739
740template <class _Tp>
741struct atomic<_Tp*>
742 : public __atomic_base<_Tp*>
743{
Howard Hinnantd2f6afb2010-12-07 23:24:41744 typedef __atomic_base<_Tp*> __base;
Howard Hinnant91e2f262010-12-07 20:46:14745 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21746 atomic() _NOEXCEPT {} // = default;
Howard Hinnant91e2f262010-12-07 20:46:14747 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21748 _LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {}
Howard Hinnant91e2f262010-12-07 20:46:14749
750 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21751 _Tp* operator=(_Tp* __d) volatile _NOEXCEPT
Howard Hinnantd2f6afb2010-12-07 23:24:41752 {__base::store(__d); return __d;}
753 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21754 _Tp* operator=(_Tp* __d) _NOEXCEPT
Howard Hinnantd2f6afb2010-12-07 23:24:41755 {__base::store(__d); return __d;}
756
757 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant91e2f262010-12-07 20:46:14758 _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst)
Howard Hinnant300c67a2012-04-11 20:14:21759 volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46760 {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14761 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21762 _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46763 {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14764 _LIBCPP_INLINE_VISIBILITY
765 _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst)
Howard Hinnant300c67a2012-04-11 20:14:21766 volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46767 {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14768 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21769 _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:46770 {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
Howard Hinnant91e2f262010-12-07 20:46:14771
772 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21773 _Tp* operator++(int) volatile _NOEXCEPT {return fetch_add(1);}
Howard Hinnant91e2f262010-12-07 20:46:14774 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21775 _Tp* operator++(int) _NOEXCEPT {return fetch_add(1);}
Howard Hinnant91e2f262010-12-07 20:46:14776 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21777 _Tp* operator--(int) volatile _NOEXCEPT {return fetch_sub(1);}
Howard Hinnant91e2f262010-12-07 20:46:14778 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21779 _Tp* operator--(int) _NOEXCEPT {return fetch_sub(1);}
Howard Hinnant91e2f262010-12-07 20:46:14780 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21781 _Tp* operator++() volatile _NOEXCEPT {return fetch_add(1) + 1;}
Howard Hinnant91e2f262010-12-07 20:46:14782 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21783 _Tp* operator++() _NOEXCEPT {return fetch_add(1) + 1;}
Howard Hinnant91e2f262010-12-07 20:46:14784 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21785 _Tp* operator--() volatile _NOEXCEPT {return fetch_sub(1) - 1;}
Howard Hinnant91e2f262010-12-07 20:46:14786 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21787 _Tp* operator--() _NOEXCEPT {return fetch_sub(1) - 1;}
Howard Hinnant91e2f262010-12-07 20:46:14788 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21789 _Tp* operator+=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;}
Howard Hinnant91e2f262010-12-07 20:46:14790 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21791 _Tp* operator+=(ptrdiff_t __op) _NOEXCEPT {return fetch_add(__op) + __op;}
Howard Hinnant91e2f262010-12-07 20:46:14792 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21793 _Tp* operator-=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;}
Howard Hinnant91e2f262010-12-07 20:46:14794 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:21795 _Tp* operator-=(ptrdiff_t __op) _NOEXCEPT {return fetch_sub(__op) - __op;}
Howard Hinnant91e2f262010-12-07 20:46:14796};
Howard Hinnant4777bf22010-12-06 23:10:08797
798// atomic_is_lock_free
799
800template <class _Tp>
801inline _LIBCPP_INLINE_VISIBILITY
802bool
Howard Hinnant300c67a2012-04-11 20:14:21803atomic_is_lock_free(const volatile atomic<_Tp>* __o) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08804{
Howard Hinnant91e2f262010-12-07 20:46:14805 return __o->is_lock_free();
Howard Hinnant4777bf22010-12-06 23:10:08806}
807
808template <class _Tp>
809inline _LIBCPP_INLINE_VISIBILITY
810bool
Howard Hinnant300c67a2012-04-11 20:14:21811atomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08812{
Howard Hinnant91e2f262010-12-07 20:46:14813 return __o->is_lock_free();
Howard Hinnant4777bf22010-12-06 23:10:08814}
815
816// atomic_init
817
818template <class _Tp>
819inline _LIBCPP_INLINE_VISIBILITY
820void
Howard Hinnant300c67a2012-04-11 20:14:21821atomic_init(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08822{
Richard Smith6186c7f2012-04-11 18:55:46823 __c11_atomic_init(&__o->__a_, __d);
Howard Hinnant4777bf22010-12-06 23:10:08824}
825
826template <class _Tp>
827inline _LIBCPP_INLINE_VISIBILITY
828void
Howard Hinnant300c67a2012-04-11 20:14:21829atomic_init(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08830{
Richard Smith6186c7f2012-04-11 18:55:46831 __c11_atomic_init(&__o->__a_, __d);
Howard Hinnant4777bf22010-12-06 23:10:08832}
833
834// atomic_store
835
836template <class _Tp>
837inline _LIBCPP_INLINE_VISIBILITY
838void
Howard Hinnant300c67a2012-04-11 20:14:21839atomic_store(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08840{
Howard Hinnant91e2f262010-12-07 20:46:14841 __o->store(__d);
Howard Hinnant4777bf22010-12-06 23:10:08842}
843
844template <class _Tp>
845inline _LIBCPP_INLINE_VISIBILITY
846void
Howard Hinnant300c67a2012-04-11 20:14:21847atomic_store(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08848{
Howard Hinnant91e2f262010-12-07 20:46:14849 __o->store(__d);
Howard Hinnant4777bf22010-12-06 23:10:08850}
851
852// atomic_store_explicit
853
854template <class _Tp>
855inline _LIBCPP_INLINE_VISIBILITY
856void
Howard Hinnant300c67a2012-04-11 20:14:21857atomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08858{
Howard Hinnant91e2f262010-12-07 20:46:14859 __o->store(__d, __m);
Howard Hinnant4777bf22010-12-06 23:10:08860}
861
862template <class _Tp>
863inline _LIBCPP_INLINE_VISIBILITY
864void
Howard Hinnant300c67a2012-04-11 20:14:21865atomic_store_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08866{
Howard Hinnant91e2f262010-12-07 20:46:14867 __o->store(__d, __m);
Howard Hinnant4777bf22010-12-06 23:10:08868}
869
870// atomic_load
871
872template <class _Tp>
873inline _LIBCPP_INLINE_VISIBILITY
874_Tp
Howard Hinnant300c67a2012-04-11 20:14:21875atomic_load(const volatile atomic<_Tp>* __o) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08876{
Howard Hinnant91e2f262010-12-07 20:46:14877 return __o->load();
Howard Hinnant4777bf22010-12-06 23:10:08878}
879
880template <class _Tp>
881inline _LIBCPP_INLINE_VISIBILITY
882_Tp
Howard Hinnant300c67a2012-04-11 20:14:21883atomic_load(const atomic<_Tp>* __o) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08884{
Howard Hinnant91e2f262010-12-07 20:46:14885 return __o->load();
Howard Hinnant4777bf22010-12-06 23:10:08886}
887
888// atomic_load_explicit
889
890template <class _Tp>
891inline _LIBCPP_INLINE_VISIBILITY
892_Tp
Howard Hinnant300c67a2012-04-11 20:14:21893atomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08894{
Howard Hinnant91e2f262010-12-07 20:46:14895 return __o->load(__m);
Howard Hinnant4777bf22010-12-06 23:10:08896}
897
898template <class _Tp>
899inline _LIBCPP_INLINE_VISIBILITY
900_Tp
Howard Hinnant300c67a2012-04-11 20:14:21901atomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08902{
Howard Hinnant91e2f262010-12-07 20:46:14903 return __o->load(__m);
Howard Hinnant4777bf22010-12-06 23:10:08904}
905
906// atomic_exchange
907
908template <class _Tp>
909inline _LIBCPP_INLINE_VISIBILITY
910_Tp
Howard Hinnant300c67a2012-04-11 20:14:21911atomic_exchange(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08912{
Howard Hinnant91e2f262010-12-07 20:46:14913 return __o->exchange(__d);
Howard Hinnant4777bf22010-12-06 23:10:08914}
915
916template <class _Tp>
917inline _LIBCPP_INLINE_VISIBILITY
918_Tp
Howard Hinnant300c67a2012-04-11 20:14:21919atomic_exchange(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08920{
Howard Hinnant91e2f262010-12-07 20:46:14921 return __o->exchange(__d);
Howard Hinnant4777bf22010-12-06 23:10:08922}
923
924// atomic_exchange_explicit
925
926template <class _Tp>
927inline _LIBCPP_INLINE_VISIBILITY
928_Tp
Howard Hinnant300c67a2012-04-11 20:14:21929atomic_exchange_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08930{
Howard Hinnant91e2f262010-12-07 20:46:14931 return __o->exchange(__d, __m);
Howard Hinnant4777bf22010-12-06 23:10:08932}
933
934template <class _Tp>
935inline _LIBCPP_INLINE_VISIBILITY
936_Tp
Howard Hinnant300c67a2012-04-11 20:14:21937atomic_exchange_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08938{
Howard Hinnant91e2f262010-12-07 20:46:14939 return __o->exchange(__d, __m);
Howard Hinnant4777bf22010-12-06 23:10:08940}
941
942// atomic_compare_exchange_weak
943
944template <class _Tp>
945inline _LIBCPP_INLINE_VISIBILITY
946bool
Howard Hinnant300c67a2012-04-11 20:14:21947atomic_compare_exchange_weak(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08948{
Howard Hinnant91e2f262010-12-07 20:46:14949 return __o->compare_exchange_weak(*__e, __d);
Howard Hinnant4777bf22010-12-06 23:10:08950}
951
952template <class _Tp>
953inline _LIBCPP_INLINE_VISIBILITY
954bool
Howard Hinnant300c67a2012-04-11 20:14:21955atomic_compare_exchange_weak(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08956{
Howard Hinnant91e2f262010-12-07 20:46:14957 return __o->compare_exchange_weak(*__e, __d);
Howard Hinnant4777bf22010-12-06 23:10:08958}
959
960// atomic_compare_exchange_strong
961
962template <class _Tp>
963inline _LIBCPP_INLINE_VISIBILITY
964bool
Howard Hinnant300c67a2012-04-11 20:14:21965atomic_compare_exchange_strong(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08966{
Howard Hinnant91e2f262010-12-07 20:46:14967 return __o->compare_exchange_strong(*__e, __d);
Howard Hinnant4777bf22010-12-06 23:10:08968}
969
970template <class _Tp>
971inline _LIBCPP_INLINE_VISIBILITY
972bool
Howard Hinnant300c67a2012-04-11 20:14:21973atomic_compare_exchange_strong(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08974{
Howard Hinnant91e2f262010-12-07 20:46:14975 return __o->compare_exchange_strong(*__e, __d);
Howard Hinnant4777bf22010-12-06 23:10:08976}
977
978// atomic_compare_exchange_weak_explicit
979
980template <class _Tp>
981inline _LIBCPP_INLINE_VISIBILITY
982bool
983atomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e,
984 _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21985 memory_order __s, memory_order __f) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08986{
Howard Hinnant91e2f262010-12-07 20:46:14987 return __o->compare_exchange_weak(*__e, __d, __s, __f);
Howard Hinnant4777bf22010-12-06 23:10:08988}
989
990template <class _Tp>
991inline _LIBCPP_INLINE_VISIBILITY
992bool
993atomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, _Tp* __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:21994 memory_order __s, memory_order __f) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:08995{
Howard Hinnant91e2f262010-12-07 20:46:14996 return __o->compare_exchange_weak(*__e, __d, __s, __f);
Howard Hinnant4777bf22010-12-06 23:10:08997}
998
999// atomic_compare_exchange_strong_explicit
1000
1001template <class _Tp>
1002inline _LIBCPP_INLINE_VISIBILITY
1003bool
1004atomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o,
1005 _Tp* __e, _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:211006 memory_order __s, memory_order __f) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:081007{
Howard Hinnant91e2f262010-12-07 20:46:141008 return __o->compare_exchange_strong(*__e, __d, __s, __f);
Howard Hinnant4777bf22010-12-06 23:10:081009}
1010
1011template <class _Tp>
1012inline _LIBCPP_INLINE_VISIBILITY
1013bool
1014atomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, _Tp* __e,
1015 _Tp __d,
Howard Hinnant300c67a2012-04-11 20:14:211016 memory_order __s, memory_order __f) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:081017{
Howard Hinnant91e2f262010-12-07 20:46:141018 return __o->compare_exchange_strong(*__e, __d, __s, __f);
Howard Hinnant4777bf22010-12-06 23:10:081019}
1020
Howard Hinnant91e2f262010-12-07 20:46:141021// atomic_fetch_add
Howard Hinnant4777bf22010-12-06 23:10:081022
1023template <class _Tp>
Howard Hinnant91e2f262010-12-07 20:46:141024inline _LIBCPP_INLINE_VISIBILITY
1025typename enable_if
1026<
1027 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1028 _Tp
1029>::type
Howard Hinnant300c67a2012-04-11 20:14:211030atomic_fetch_add(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant4777bf22010-12-06 23:10:081031{
Howard Hinnant91e2f262010-12-07 20:46:141032 return __o->fetch_add(__op);
1033}
Howard Hinnant4777bf22010-12-06 23:10:081034
Howard Hinnant91e2f262010-12-07 20:46:141035template <class _Tp>
1036inline _LIBCPP_INLINE_VISIBILITY
1037typename enable_if
1038<
1039 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1040 _Tp
1041>::type
Howard Hinnant300c67a2012-04-11 20:14:211042atomic_fetch_add(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141043{
1044 return __o->fetch_add(__op);
1045}
Howard Hinnant4777bf22010-12-06 23:10:081046
Howard Hinnant91e2f262010-12-07 20:46:141047template <class _Tp>
1048inline _LIBCPP_INLINE_VISIBILITY
1049_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211050atomic_fetch_add(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141051{
1052 return __o->fetch_add(__op);
1053}
1054
1055template <class _Tp>
1056inline _LIBCPP_INLINE_VISIBILITY
1057_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211058atomic_fetch_add(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141059{
1060 return __o->fetch_add(__op);
1061}
1062
1063// atomic_fetch_add_explicit
1064
1065template <class _Tp>
1066inline _LIBCPP_INLINE_VISIBILITY
1067typename enable_if
1068<
1069 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1070 _Tp
1071>::type
Howard Hinnant300c67a2012-04-11 20:14:211072atomic_fetch_add_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141073{
1074 return __o->fetch_add(__op, __m);
1075}
1076
1077template <class _Tp>
1078inline _LIBCPP_INLINE_VISIBILITY
1079typename enable_if
1080<
1081 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1082 _Tp
1083>::type
Howard Hinnant300c67a2012-04-11 20:14:211084atomic_fetch_add_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141085{
1086 return __o->fetch_add(__op, __m);
1087}
1088
1089template <class _Tp>
1090inline _LIBCPP_INLINE_VISIBILITY
1091_Tp*
1092atomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
Howard Hinnant300c67a2012-04-11 20:14:211093 memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141094{
1095 return __o->fetch_add(__op, __m);
1096}
1097
1098template <class _Tp>
1099inline _LIBCPP_INLINE_VISIBILITY
1100_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211101atomic_fetch_add_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141102{
1103 return __o->fetch_add(__op, __m);
1104}
1105
1106// atomic_fetch_sub
1107
1108template <class _Tp>
1109inline _LIBCPP_INLINE_VISIBILITY
1110typename enable_if
1111<
1112 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1113 _Tp
1114>::type
Howard Hinnant300c67a2012-04-11 20:14:211115atomic_fetch_sub(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141116{
1117 return __o->fetch_sub(__op);
1118}
1119
1120template <class _Tp>
1121inline _LIBCPP_INLINE_VISIBILITY
1122typename enable_if
1123<
1124 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1125 _Tp
1126>::type
Howard Hinnant300c67a2012-04-11 20:14:211127atomic_fetch_sub(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141128{
1129 return __o->fetch_sub(__op);
1130}
1131
1132template <class _Tp>
1133inline _LIBCPP_INLINE_VISIBILITY
1134_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211135atomic_fetch_sub(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141136{
1137 return __o->fetch_sub(__op);
1138}
1139
1140template <class _Tp>
1141inline _LIBCPP_INLINE_VISIBILITY
1142_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211143atomic_fetch_sub(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141144{
1145 return __o->fetch_sub(__op);
1146}
1147
1148// atomic_fetch_sub_explicit
1149
1150template <class _Tp>
1151inline _LIBCPP_INLINE_VISIBILITY
1152typename enable_if
1153<
1154 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1155 _Tp
1156>::type
Howard Hinnant300c67a2012-04-11 20:14:211157atomic_fetch_sub_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141158{
1159 return __o->fetch_sub(__op, __m);
1160}
1161
1162template <class _Tp>
1163inline _LIBCPP_INLINE_VISIBILITY
1164typename enable_if
1165<
1166 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1167 _Tp
1168>::type
Howard Hinnant300c67a2012-04-11 20:14:211169atomic_fetch_sub_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141170{
1171 return __o->fetch_sub(__op, __m);
1172}
1173
1174template <class _Tp>
1175inline _LIBCPP_INLINE_VISIBILITY
1176_Tp*
1177atomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
Howard Hinnant300c67a2012-04-11 20:14:211178 memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141179{
1180 return __o->fetch_sub(__op, __m);
1181}
1182
1183template <class _Tp>
1184inline _LIBCPP_INLINE_VISIBILITY
1185_Tp*
Howard Hinnant300c67a2012-04-11 20:14:211186atomic_fetch_sub_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141187{
1188 return __o->fetch_sub(__op, __m);
1189}
1190
1191// atomic_fetch_and
1192
1193template <class _Tp>
1194inline _LIBCPP_INLINE_VISIBILITY
1195typename enable_if
1196<
1197 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1198 _Tp
1199>::type
Howard Hinnant300c67a2012-04-11 20:14:211200atomic_fetch_and(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141201{
1202 return __o->fetch_and(__op);
1203}
1204
1205template <class _Tp>
1206inline _LIBCPP_INLINE_VISIBILITY
1207typename enable_if
1208<
1209 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1210 _Tp
1211>::type
Howard Hinnant300c67a2012-04-11 20:14:211212atomic_fetch_and(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141213{
1214 return __o->fetch_and(__op);
1215}
1216
1217// atomic_fetch_and_explicit
1218
1219template <class _Tp>
1220inline _LIBCPP_INLINE_VISIBILITY
1221typename enable_if
1222<
1223 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1224 _Tp
1225>::type
Howard Hinnant300c67a2012-04-11 20:14:211226atomic_fetch_and_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141227{
1228 return __o->fetch_and(__op, __m);
1229}
1230
1231template <class _Tp>
1232inline _LIBCPP_INLINE_VISIBILITY
1233typename enable_if
1234<
1235 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1236 _Tp
1237>::type
Howard Hinnant300c67a2012-04-11 20:14:211238atomic_fetch_and_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141239{
1240 return __o->fetch_and(__op, __m);
1241}
1242
1243// atomic_fetch_or
1244
1245template <class _Tp>
1246inline _LIBCPP_INLINE_VISIBILITY
1247typename enable_if
1248<
1249 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1250 _Tp
1251>::type
Howard Hinnant300c67a2012-04-11 20:14:211252atomic_fetch_or(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141253{
1254 return __o->fetch_or(__op);
1255}
1256
1257template <class _Tp>
1258inline _LIBCPP_INLINE_VISIBILITY
1259typename enable_if
1260<
1261 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1262 _Tp
1263>::type
Howard Hinnant300c67a2012-04-11 20:14:211264atomic_fetch_or(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141265{
1266 return __o->fetch_or(__op);
1267}
1268
1269// atomic_fetch_or_explicit
1270
1271template <class _Tp>
1272inline _LIBCPP_INLINE_VISIBILITY
1273typename enable_if
1274<
1275 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1276 _Tp
1277>::type
Howard Hinnant300c67a2012-04-11 20:14:211278atomic_fetch_or_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141279{
1280 return __o->fetch_or(__op, __m);
1281}
1282
1283template <class _Tp>
1284inline _LIBCPP_INLINE_VISIBILITY
1285typename enable_if
1286<
1287 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1288 _Tp
1289>::type
Howard Hinnant300c67a2012-04-11 20:14:211290atomic_fetch_or_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141291{
1292 return __o->fetch_or(__op, __m);
1293}
1294
1295// atomic_fetch_xor
1296
1297template <class _Tp>
1298inline _LIBCPP_INLINE_VISIBILITY
1299typename enable_if
1300<
1301 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1302 _Tp
1303>::type
Howard Hinnant300c67a2012-04-11 20:14:211304atomic_fetch_xor(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141305{
1306 return __o->fetch_xor(__op);
1307}
1308
1309template <class _Tp>
1310inline _LIBCPP_INLINE_VISIBILITY
1311typename enable_if
1312<
1313 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1314 _Tp
1315>::type
Howard Hinnant300c67a2012-04-11 20:14:211316atomic_fetch_xor(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141317{
1318 return __o->fetch_xor(__op);
1319}
1320
1321// atomic_fetch_xor_explicit
1322
1323template <class _Tp>
1324inline _LIBCPP_INLINE_VISIBILITY
1325typename enable_if
1326<
1327 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1328 _Tp
1329>::type
Howard Hinnant300c67a2012-04-11 20:14:211330atomic_fetch_xor_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141331{
1332 return __o->fetch_xor(__op, __m);
1333}
1334
1335template <class _Tp>
1336inline _LIBCPP_INLINE_VISIBILITY
1337typename enable_if
1338<
1339 is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
1340 _Tp
1341>::type
Howard Hinnant300c67a2012-04-11 20:14:211342atomic_fetch_xor_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
Howard Hinnant91e2f262010-12-07 20:46:141343{
1344 return __o->fetch_xor(__op, __m);
1345}
Howard Hinnant4777bf22010-12-06 23:10:081346
Howard Hinnant770d1c42010-12-08 17:20:281347// flag type and operations
1348
1349typedef struct atomic_flag
1350{
David Chisnall83b2c842011-12-19 11:44:201351 _Atomic(bool) __a_;
Howard Hinnant770d1c42010-12-08 17:20:281352
1353 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211354 bool test_and_set(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:461355 {return __c11_atomic_exchange(&__a_, true, __m);}
Howard Hinnant770d1c42010-12-08 17:20:281356 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211357 bool test_and_set(memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:461358 {return __c11_atomic_exchange(&__a_, true, __m);}
Howard Hinnant770d1c42010-12-08 17:20:281359 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211360 void clear(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:461361 {__c11_atomic_store(&__a_, false, __m);}
Howard Hinnant770d1c42010-12-08 17:20:281362 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211363 void clear(memory_order __m = memory_order_seq_cst) _NOEXCEPT
Richard Smith6186c7f2012-04-11 18:55:461364 {__c11_atomic_store(&__a_, false, __m);}
Howard Hinnant770d1c42010-12-08 17:20:281365
1366 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211367 atomic_flag() _NOEXCEPT {} // = default;
Howard Hinnant770d1c42010-12-08 17:20:281368 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant300c67a2012-04-11 20:14:211369 atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {}
Howard Hinnant770d1c42010-12-08 17:20:281370
1371#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1372 atomic_flag(const atomic_flag&) = delete;
1373 atomic_flag& operator=(const atomic_flag&) = delete;
1374 atomic_flag& operator=(const atomic_flag&) volatile = delete;
1375#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1376private:
1377 atomic_flag(const atomic_flag&);
1378 atomic_flag& operator=(const atomic_flag&);
1379 atomic_flag& operator=(const atomic_flag&) volatile;
1380#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
1381} atomic_flag;
1382
1383inline _LIBCPP_INLINE_VISIBILITY
1384bool
Howard Hinnant300c67a2012-04-11 20:14:211385atomic_flag_test_and_set(volatile atomic_flag* __o) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281386{
1387 return __o->test_and_set();
1388}
1389
1390inline _LIBCPP_INLINE_VISIBILITY
1391bool
Howard Hinnant300c67a2012-04-11 20:14:211392atomic_flag_test_and_set(atomic_flag* __o) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281393{
1394 return __o->test_and_set();
1395}
1396
1397inline _LIBCPP_INLINE_VISIBILITY
1398bool
Howard Hinnant300c67a2012-04-11 20:14:211399atomic_flag_test_and_set_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281400{
1401 return __o->test_and_set(__m);
1402}
1403
1404inline _LIBCPP_INLINE_VISIBILITY
1405bool
Howard Hinnant300c67a2012-04-11 20:14:211406atomic_flag_test_and_set_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281407{
1408 return __o->test_and_set(__m);
1409}
1410
1411inline _LIBCPP_INLINE_VISIBILITY
1412void
Howard Hinnant300c67a2012-04-11 20:14:211413atomic_flag_clear(volatile atomic_flag* __o) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281414{
1415 __o->clear();
1416}
1417
1418inline _LIBCPP_INLINE_VISIBILITY
1419void
Howard Hinnant300c67a2012-04-11 20:14:211420atomic_flag_clear(atomic_flag* __o) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281421{
1422 __o->clear();
1423}
1424
1425inline _LIBCPP_INLINE_VISIBILITY
1426void
Howard Hinnant300c67a2012-04-11 20:14:211427atomic_flag_clear_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281428{
1429 __o->clear(__m);
1430}
1431
1432inline _LIBCPP_INLINE_VISIBILITY
1433void
Howard Hinnant300c67a2012-04-11 20:14:211434atomic_flag_clear_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281435{
1436 __o->clear(__m);
1437}
1438
1439// fences
1440
1441inline _LIBCPP_INLINE_VISIBILITY
1442void
Howard Hinnant300c67a2012-04-11 20:14:211443atomic_thread_fence(memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281444{
Richard Smith6186c7f2012-04-11 18:55:461445 __c11_atomic_thread_fence(__m);
Howard Hinnant770d1c42010-12-08 17:20:281446}
1447
1448inline _LIBCPP_INLINE_VISIBILITY
1449void
Howard Hinnant300c67a2012-04-11 20:14:211450atomic_signal_fence(memory_order __m) _NOEXCEPT
Howard Hinnant770d1c42010-12-08 17:20:281451{
Richard Smith6186c7f2012-04-11 18:55:461452 __c11_atomic_signal_fence(__m);
Howard Hinnant770d1c42010-12-08 17:20:281453}
1454
Howard Hinnantd2f6afb2010-12-07 23:24:411455// Atomics for standard typedef types
1456
1457typedef atomic<char> atomic_char;
1458typedef atomic<signed char> atomic_schar;
1459typedef atomic<unsigned char> atomic_uchar;
1460typedef atomic<short> atomic_short;
1461typedef atomic<unsigned short> atomic_ushort;
1462typedef atomic<int> atomic_int;
1463typedef atomic<unsigned int> atomic_uint;
1464typedef atomic<long> atomic_long;
1465typedef atomic<unsigned long> atomic_ulong;
1466typedef atomic<long long> atomic_llong;
1467typedef atomic<unsigned long long> atomic_ullong;
1468typedef atomic<char16_t> atomic_char16_t;
1469typedef atomic<char32_t> atomic_char32_t;
1470typedef atomic<wchar_t> atomic_wchar_t;
1471
1472typedef atomic<int_least8_t> atomic_int_least8_t;
1473typedef atomic<uint_least8_t> atomic_uint_least8_t;
1474typedef atomic<int_least16_t> atomic_int_least16_t;
1475typedef atomic<uint_least16_t> atomic_uint_least16_t;
1476typedef atomic<int_least32_t> atomic_int_least32_t;
1477typedef atomic<uint_least32_t> atomic_uint_least32_t;
1478typedef atomic<int_least64_t> atomic_int_least64_t;
1479typedef atomic<uint_least64_t> atomic_uint_least64_t;
1480
1481typedef atomic<int_fast8_t> atomic_int_fast8_t;
1482typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
1483typedef atomic<int_fast16_t> atomic_int_fast16_t;
1484typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
1485typedef atomic<int_fast32_t> atomic_int_fast32_t;
1486typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
1487typedef atomic<int_fast64_t> atomic_int_fast64_t;
1488typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
1489
1490typedef atomic<intptr_t> atomic_intptr_t;
1491typedef atomic<uintptr_t> atomic_uintptr_t;
1492typedef atomic<size_t> atomic_size_t;
1493typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
1494typedef atomic<intmax_t> atomic_intmax_t;
1495typedef atomic<uintmax_t> atomic_uintmax_t;
1496
Howard Hinnant767ae2b2010-09-29 21:20:031497#define ATOMIC_FLAG_INIT {false}
Howard Hinnant611fdaf2010-10-04 18:52:541498#define ATOMIC_VAR_INIT(__v) {__v}
1499
Howard Hinnant770d1c42010-12-08 17:20:281500// lock-free property
Howard Hinnant611fdaf2010-10-04 18:52:541501
Howard Hinnant770d1c42010-12-08 17:20:281502#define ATOMIC_CHAR_LOCK_FREE 0
1503#define ATOMIC_CHAR16_T_LOCK_FREE 0
1504#define ATOMIC_CHAR32_T_LOCK_FREE 0
1505#define ATOMIC_WCHAR_T_LOCK_FREE 0
1506#define ATOMIC_SHORT_LOCK_FREE 0
1507#define ATOMIC_INT_LOCK_FREE 0
1508#define ATOMIC_LONG_LOCK_FREE 0
1509#define ATOMIC_LLONG_LOCK_FREE 0
1510
Howard Hinnant154002b2011-03-31 16:39:391511#endif // !__has_feature(cxx_atomic)
1512
Howard Hinnant8f73c632010-09-27 21:17:381513_LIBCPP_END_NAMESPACE_STD
1514
1515#endif // _LIBCPP_ATOMIC